package keeto.com.vn.classified.task;

import java.io.IOException;

import keeto.com.vn.classified.core.ClassifiedCore;
import keeto.com.vn.classified.core.ClassifiedListener;
import keeto.com.vn.classified.network.IProtocol;
import keeto.com.vn.classified.request.GetAndroidInterestShopRequest;
import keeto.com.vn.classified.response.GetAndroidInterestShopResponse;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;
public class TaskGetAndroidInterestShop extends AbstractTask{

	String guarantyStoreId;
	String userName;
	String type;


	public TaskGetAndroidInterestShop(ClassifiedListener listener, ClassifiedCore core,String guaranteStoreId,String userName , String Type) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.guarantyStoreId= guaranteStoreId;
		this.userName= userName;
		this.type = Type;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
	IOException {
		GetAndroidInterestShopRequest request = new GetAndroidInterestShopRequest();
		request.setGuaranteStoreId(guarantyStoreId);
		request.setUserName(userName);
		request.setType(type);
		GetAndroidInterestShopResponse response = json.getAndroidInterestShop(request); 
		for (ClassifiedListener listener : listeners){
			listener.finishGetAndroidInterestShop(response.getReturnCode(), response.isInterest());
		}

	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for (ClassifiedListener listener : listeners){
			listener.finishGetAndroidInterestShop(IProtocol.STATUS_CODE_CONNECTION_TIMEOUT_502, false);
		}
	}

}
